package wangwenjun.phase2.concurrencypattern.activeobject.dynamicproxy.framework;

/**
 * @author ChangLiang
 * @date 2020/6/18
 */
class ActiveObjectServiceDaemonThread extends Thread {

    private final ActiveObjectMessageQueue queue;

    public ActiveObjectServiceDaemonThread(ActiveObjectMessageQueue queue) {
        super("active-object-service-daemon-thread");
        this.queue = queue;
        setDaemon(true);
    }

    @Override
    public void run() {
        while (true) {
            ActiveObjectMessage message = queue.take();
            message.execute();
        }
    }
}
